package com.example.daytest.twothreesheji.Singleton;

/**
 * @author heyu
 * @title: Singleton
 * @description:单例模式双重校验
 * @date 2022/3/9下午2:20
 */
public class Singleton {

    private static  volatile Singleton instance=null;
    private Singleton(){
        System.out.println(Thread.currentThread().getName()+"\t 我是构造方法");
    }
    public static Singleton getInstance(){
        if(instance==null){
            synchronized (Singleton.class){
                instance=new Singleton();
            }

        }
        return instance;
    }


}
